#include <ut/UnitTest.h>
#include <illib/Log.h>
#include <illib/System.h>
#include <stdio.h>
#include <stdarg.h>

using namespace illib;

namespace ut{
	namespace {
		size_t successes = 0;
		size_t failures = 0;
	};
	bool showTests = false;
	void test(const char *file, uint32_t line, bool result, const char* expr, const char *fmt, ...) {
		if (result) {
			successes++;
			if (showTests){
				Console::print("%s:%d SUCCESS: ", file, line);
				va_list args;
				va_start (args, fmt);
				vprintf(fmt, args);
				va_end (args);
				Console::print(" (%s)\n", expr);
			}
		}
		if (!result) {
			failures++;
			Console::print("%s:%d FAILED: ", file, line);
			va_list args;
			va_start (args, fmt);
			vprintf(fmt, args);
			va_end (args);
			Console::print(" (%s) == %d \n", expr, result);
		}
	}
	void summary(){
		Console::print("Test successes: %d\nTest failures: %d\n", successes, failures);
	}
}

